package com.acc.store.contorller;

import com.acc.store.common.Result;
import com.acc.store.entity.Inventory;
import com.acc.store.service.InventoryService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RequestMapping("/inventory")
@RestController
@Slf4j
@Tag(name = "库存操作")
public class InventoryContorller {
    @Autowired
    InventoryService inventoryService;

    @PutMapping("/grounding")
    @Operation(summary = "上架")
    public Result grounding(@RequestParam Long id,@RequestParam Integer num){
        inventoryService.grouding(id,num);
        return Result.success(null);
    }

    @GetMapping("/list")
    @Operation(summary = "仓储分页")
    public Result page(@RequestParam Map<String, Object> params) {
        IPage page = inventoryService.getPage(params);
        return Result.success(page);
    }

    @PostMapping("/save")
    @Operation(summary = "新品入库")
    public Result save(@RequestBody Inventory inventory) {
        inventoryService.saveOne(inventory);
        return Result.success(null);
    }
}
